/**
 * 
 */
package com.netflexitysolutions.amazonws.sdb;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * @author netflexity
 *
 */
public class Item {

	private String identifier;
	private Map<String, ItemAttribute> attributeMap = new LinkedHashMap<String, ItemAttribute>();
	
	/**
	 * @return the identifier
	 */
	public String getIdentifier() {
		return identifier;
	}
	/**
	 * @param identifier the identifier to set
	 */
	public void setIdentifier(String identifier) {
		this.identifier = identifier;
	}
	/**
	 * @return the attributes
	 */
	public List<ItemAttribute> getAttributes() {
		return new ArrayList<ItemAttribute>(attributeMap.values());
	}
	/**
	 * @param attribute the attribute to add
	 */
	public void addAttribute(String name, String value, boolean replace) {
		if(attributeMap.containsKey(name)){
			ItemAttribute attribute = attributeMap.get(name);
			attribute.addValue(value);
		}
		else{
			this.attributeMap.put(name, new ItemAttribute(name, value, replace));
		}
	}
}
